<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css"/>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
		<style type="text/css">
			.main{
				width: 100%;
				background-color: white;
			}
			.main>div{
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: flex-start;
				height: 44px;
				margin: 0.4em 0;
				
			}
			.dl,.dr,.dc,.dcpsword{
				height: 100%;
				line-height: 44px;
			}
			.dl{
				width: 25%;
				text-align: center;
			}
			.dr{
				width: 25%;
				text-align: center;
				
			}
			.dc{
				width: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.dcpsword{
				width: 70%;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			input{
				width: 100%;
				border: 0;
				height: 100%;
				padding-left: 1em;
			}
			*{
				font-size: 0.9em;
			}
			input[type=password]{
				    margin-bottom: 0px;
				    border:0;
			}
			input[type=text]{
				margin-bottom: 0px;
				border:0;
			}
			
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">修改密码</h1>
		</header>
		<div class="mui-content">
		    
		    <!--<div class="main">
		    	<div class="border-b">
		    		<div class="dl border-r">
		    			+86
		    		</div>
		    		<div class="dc">
		    			<input id="phone" type="" name="" id="" value="" placeholder="输入电话"/>
		    		</div>
		    		<div class="dr" id="cfbut">
		    			发送验证码
		    		</div>
		    	</div>
		    </div>-->
		    
		    <div class="main">
		    	<div class="">
		    		<div class="dl border-r">
		    			输入旧密码
		    		</div>
		    		<div class="dcpsword mui-input-row mui-password">
		    			<input type="password" name="" class="mui-input-password"  id="oldpsword" value="" placeholder="输入旧密码"/>
		    		</div>
		    		
		    	</div>
		    </div>
		    
		    <div class="main">
		    	<div class="">
		    		<div class="dl border-r">
		    			输入新密码
		    		</div>
		    		<div class="dcpsword mui-input-row mui-password">
		    			<input type="password" name="" class="mui-input-password"  id="psword" value="" placeholder="输入新密码"/>
		    		</div>
		    		
		    	</div>
		    </div>
		    <div class="main">
		    	<div class="">
		    		<div class="dl border-r">
		    			确认密码
		    		</div>
		    		<div class="dcpsword mui-input-row mui-password">
		    			<input type="password" name="" class="mui-input-password"  id="psword2" value="" placeholder="输入确认密码"/>
		    		</div>
		    	</div>
		    </div>
		    
		    
		    
		    <div class="footdiv">
		    	<button id="findbut" type="button" class="mui-btn mui-btn-blue mui-btn-block">确定</button>
		    </div>
		    
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var i = 60,flag = true;
			window.onload = function(){
				$("#cfbut").on("tap",function(){
					var pvalue = g("phone").value;
					
					if(!phone_validation(pvalue)){
						//mui.toast("请输入手机号");
						return;
					}
				if(flag){
					var data = {
						url:"/api/code/get",
						data:{
							phone:pvalue,
							type:2
						}
					}
					ajax(data,function(res){
						console.log(res);
						mui.toast(res.msg);
						var time;
						flag = !flag;
						//mui.toast('验证码已发送到您的手机，请稍等...');
						time = setInterval(function(){
							i--;
							$("#cfbut").html(i);
							if(i < 1){
								i = 60;
								 clearInterval(time);
								 mui.toast("如果验证码未收到，请重发");
								 flag = !flag;
								 $("#cfbut").html("重发");
							}
						},1000);
					});
					
				}
			})
				
				
				g("findbut").addEventListener("tap",function(res){
					
					var oldpsword = g("oldpsword").value||"",
						p1 = g("psword").value,
						p2 = g("psword2").value;
					if( "" == oldpsword){
						mui.toast("请输入旧密码");
						return;
					}
					if( "" == p1){
						mui.toast("请输入新密码");
						return;
					}
					if(p1 !== p2){
						mui.toast("两次密码输入不一致，请确认密码");
						return;
					}
					
					var data = {
						url:"/api/employee/edit_pwd2",
						data:{
							access_token:acctoken(),
							old_password:oldpsword,
							new_password:p1,
						}
					}
					ajax(data,function(res){
						console.log(res)
						mui.toast(res.msg);
						setTimeout(function(){
							mui.back();
						},300)
					})
					
				})
			}
			
		</script>
	</body>

</html>